<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<style>
    div {
        margin: 0 auto;

    }

    #one {
        width: 500px;
        height: 500px;
        line-height: 500px;
        background: red;
    }

    #two {
        width: 350px;
        height: 350px;
        background: #000;
    }

    #three {
        width: 200px;
        height: 200px;
        background: #fff;
    }
</style>
<div id="one" onclick="alert('我是最大')">
    <div id="two" onclick="alert('我是中等');stopbubble(arguments[0]);">
        <div id="three" onclick="alert('我是最小')"></div>
    </div>
</div>
<script src="modules/jquery-3.2.1.js"></script>
<script type="text/javascript">
    function count(a) {
        if (a == 1) {
            return 1;
        }
        //console.log(arguments);
        return a + arguments.callee(--a);//调用自己,经典的阶乘函数
    }
    var mm = count(10);
    //alert(mm);

    /**递归
     function digui(c) {
        console.log(c);
        if (c != 1) {
            window.digui(--c);
        }
    }
     digui(5);*/

    /**closure
     function add() {
        var n = 1;
        return function () {
            return n++;
        }
    }
     var addfun = add();
     console.log(addfun());//1
     console.log(addfun());//2

     var addfun1 = add();//新增的函数不会覆盖以前的内存
     console.log(addfun1());//1
     console.log(addfun1());//2

     console.log(addfun());//3*/

    //函数add内的变量，被保存在内存中

    var aa = document.getElementById('three');
    aa.addEventListener('click', function () {
        alert('aaaa');
    }, true);
    function stopbubble(e) {
        e.stopPropagation();//stop bubble event on this node
    }

   /** function DOMEval(code, doc) {
        doc = doc || document;

        var script = doc.createElement("script");

        script.text = code;
        doc.head.appendChild(script).parentNode.removeChild(script);
    }
    DOMEval("document.querySelector('#one').addEventListener('click', function () {alert(123);})");*/
</script>
</body>
</html>